package hx.bean;

import hx.config.Global;

/**
 * 封装分页参数
 *
 * @author HX<titanrain@163.com>
 */
public class PageParam {

    private long pageNo = 1;
    private int pageSize = Global.pageSize;

    public PageParam(long pageNo, int pageSize) {
        if (pageNo > 0) {
            this.pageNo = pageNo;
        }
        if (pageSize > 0) {
            this.pageSize = pageSize;
        }
    }

    public long startIndex() {
        long startIndex = (this.pageNo - 1) * this.pageSize;
        return startIndex < 0 ? 0L : startIndex;
    }

    public long pageNo() {
        return pageNo;
    }

    public int pageSize() {
        return pageSize;
    }
}